#! /usr/bin/env python
# -*- coding: utf-8 -*-

# *************************************************************
#     Filename @  fib.py
#       Author @  Huoty
#  Create date @  2016-05-11 20:34:11
#  Description @  
# *************************************************************

class Fib(object):
    def __getitem__(self, n):
        if isinstance(n, int):
            a, b = 1, 1
            for x in range(n):
                a, b = b, a + b
            return a
        elif isinstance(n, slice):
            start = n.start
            stop = n.stop
            a, b = 1, 1
            L = []
            for x in range(stop):
                if x >= start:
                    L.append(a)
                a, b = b, a + b
            return L
        else:
            raise TypeError("Fib indices must be integers")
            
# Script starts from here

if __name__ == "__main__":
    f = Fib()
    print f[0:5]
    print f[:10]
